package com.zb.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.constant.StoreConstant;
import com.zb.entity.ZjStoreLogistics;
import com.zb.mapper.ZjStoreLogisticsMapper;
import com.zb.service.ZjStoreLogisticsService;
import com.zb.vo.StoreInboundLogisticsVo;
import com.zb.vo.StoreLogisticsVo;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 出入库物流表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2024-01-08
 */
@Service
public class ZjStoreLogisticsServiceImpl extends ServiceImpl<ZjStoreLogisticsMapper, ZjStoreLogistics> implements ZjStoreLogisticsService {

    // 保存出库物流
    @Override
    public void saveStoreOutboundLogistic(Long custAccId, Long storeOutboundId, StoreLogisticsVo logisticsVo) {
        ZjStoreLogistics logistics = new ZjStoreLogistics();
        logistics.setId(storeOutboundId);
        logistics.setCustAccId(custAccId);
        logistics.setType(StoreConstant.STORE_OUT_IN_TYPE_2);
        logistics.setStatus(1);
        logistics.setStoreOutboundCode(logisticsVo.getStoreOutboundCode());
        logistics.setCompany(StringUtils.isNotBlank(logisticsVo.getLogisticsName())? logisticsVo.getLogisticsName() : "");
        logistics.setCode(StringUtils.isNotBlank(logisticsVo.getLogisticsCode())? logisticsVo.getLogisticsCode() : "");
        logistics.setLogisticsNo(StringUtils.isNotBlank(logisticsVo.getLogisticsNo())? logisticsVo.getLogisticsNo() : "");
        logistics.setSendTime(logisticsVo.getTime());
        logistics.setRemark(StringUtils.isNotBlank(logisticsVo.getRemark())? logisticsVo.getRemark() : "");
        this.saveOrUpdate(logistics);
    }

    // 保存入库物流
    @Override
    public void saveInboundLogistics(Long custAccId, Long storeIboundId, StoreLogisticsVo logisticsVo) {
        ZjStoreLogistics logistics = new ZjStoreLogistics();
        logistics.setId(storeIboundId);
        logistics.setCustAccId(custAccId);
        logistics.setType(StoreConstant.STORE_OUT_IN_TYPE_1);
        logistics.setStatus(1);
        logistics.setStoreOutboundCode(logisticsVo.getStoreOutboundCode());
        logistics.setCompany(StringUtils.isNotBlank(logisticsVo.getLogisticsName())? logisticsVo.getLogisticsName() : "");
        logistics.setCode(StringUtils.isNotBlank(logisticsVo.getLogisticsCode())? logisticsVo.getLogisticsCode() : "");
        logistics.setLogisticsNo(StringUtils.isNotBlank(logisticsVo.getLogisticsNo())? logisticsVo.getLogisticsNo() : "");
        logistics.setSendTime(logisticsVo.getTime());
        logistics.setRemark(StringUtils.isNotBlank(logisticsVo.getRemark())? logisticsVo.getRemark() : "");
        this.saveOrUpdate(logistics);
    }
}
